package com.ruoyi.common.net.mqtt;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.integration.mqtt.event.MqttConnectionFailedEvent;
import org.springframework.integration.mqtt.event.MqttMessageDeliveredEvent;
import org.springframework.integration.mqtt.event.MqttMessageSentEvent;
import org.springframework.integration.mqtt.event.MqttSubscribedEvent;
import org.springframework.stereotype.Component;
/**
 * @author xumh
 * @title: MqttListener
 * @description: TODO
 * @date 2024/12/1814:56
 */
@Component
public class MqttListener {
    private static Logger log = LoggerFactory.getLogger(MqttListener.class);

    public MqttListener() {
    }

    @EventListener(
            classes = {MqttConnectionFailedEvent.class}
    )
    public void listenerAction(MqttConnectionFailedEvent mqttConnectionFailedEvent) {
        log.info("连接失败的事件通知");
    }

    @EventListener(
            classes = {MqttMessageSentEvent.class}
    )
    public void listenerAction(MqttMessageSentEvent mqttMessageSentEvent) {
        log.info("已发送的事件通知");
    }

    @EventListener(
            classes = {MqttMessageDeliveredEvent.class}
    )
    public void listenerAction(MqttMessageDeliveredEvent mqttMessageDeliveredEvent) {
        log.info("已传输完成的事件通知");
    }

    @EventListener(
            classes = {MqttSubscribedEvent.class}
    )
    public void listenerAction(MqttSubscribedEvent mqttSubscribedEvent) {
        log.info("消息订阅的事件通知");
    }
}

